package com.ksic.community.web;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
import org.springmodules.validation.commons.DefaultBeanValidator;

import com.ksic.community.service.UserService;
import com.ksic.community.vo.UserVO;

import egovframework.example.sample.service.EgovSampleService;
import egovframework.rte.fdl.property.EgovPropertyService;

@Controller
public class CommnityController {

	/** EgovSampleService */
	@Resource(name = "sampleService")
	private EgovSampleService sampleService;

	/** EgovPropertyService */
	@Resource(name = "propertiesService")
	protected EgovPropertyService propertiesService;

	/** Validator */
	@Resource(name = "beanValidator")
	protected DefaultBeanValidator beanValidator;

	@Resource(name = "userService")
	private UserService userService;

	@RequestMapping(value = "/commMap/login.do")
	public String test(@ModelAttribute("useVo") UserVO userVo,
			HttpServletRequest request, ModelMap model) throws Exception {

		// UserVO userVo = new UserVO();

		userVo.setUserid(request.getParameter("userid"));
		userVo.setUserpw(request.getParameter("userpw"));
		userVo.setUsername(request.getParameter("username"));

		/*
		 * String userid = request.getParameter("userid"); String userpw =
		 * request.getParameter("userpw"); String username =
		 * request.getParameter("username");
		 */

		String userid = userVo.getUserid();
		String userpw = userVo.getUserpw();
		String username = userVo.getUsername();

		System.out.println(userid);

		userVo = userService.getLoginInfo(userVo);

		System.out.println(userVo.getUsername());
		// userVo.setUserid(userid);

		model.addAttribute("userVo", userVo);

		return "/commMap/signUp";
	}
}
